package com.andy.android.serialporttest;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.Adapter;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;

import java.util.List;

public class MyAdapter extends Adapter<MyViewHolder> {

    private List<String> content;

    public MyAdapter(List<String> content) {
        this.content = content;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        TextView textView = new TextView(parent.getContext());
        return new MyViewHolder(textView);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        if (holder.itemView instanceof TextView) {
            ((TextView) holder.itemView).setText(content.get(position));
        }
    }

    @Override
    public int getItemCount() {
        return content.size();
    }
}

class MyViewHolder extends ViewHolder {

    public MyViewHolder(@NonNull View itemView) {
        super(itemView);
    }
}
